package org.lemon.cla.config;


import com.qcloud.cos.COSClient;
import com.qcloud.cos.ClientConfig;
import com.qcloud.cos.auth.BasicCOSCredentials;
import com.qcloud.cos.auth.COSCredentials;
import com.qcloud.cos.http.HttpProtocol;
import com.qcloud.cos.region.Region;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class CosClientConfig {

    private String secretId = "AKIDb7SaXHo8E6qUxDF4vfFepAVny1gCVaAj";
    private String secretKey="Yv8Ws8E7qMjut3A6uiOuNbq15YrAPVRG";

    private String region = "ap-shanghai";

    @Bean
    public COSClient cosClient() {
        // 1 传入腾讯云 COS 账号的 SecretId，SecretKey。
        COSCredentials cred = new BasicCOSCredentials(secretId, secretKey);

        // 2 clientConfig 中包含了 COS client 的设置
        ClientConfig clientConfig = new ClientConfig(new Region(region));
        // 这里推荐设置 https，域名是 cos.ap-guangzhou.myqcloud.com
        clientConfig.setHttpProtocol(HttpProtocol.https);

        // 3 生成 cos 客户端。
        return new COSClient(cred, clientConfig);
    }
}